/**
 * Created by Freeman on 2018/1/6.
 */
import React from 'react'
import { StyleSheet, TouchableOpacity, View } from 'react-native'
import PropTypes from 'prop-types'
import { COLOR } from '../../config'

const Block = ({children, style, onPress}) => {

  return (
    onPress ? <TouchableOpacity
        onPress={onPress}
        style={[styles.container, style]}
      >
        {children}
      </TouchableOpacity>
      : <View style={[styles.container, style]}>
        {children}
      </View>
  )
}

const styles = StyleSheet.create({
  container: {
    padding: 10,
    backgroundColor: COLOR.backgroundLighter
  }
})

Block.propTypes = {
  onPress:PropTypes.func,
  style:PropTypes.oneOfType([
    PropTypes.object,
    PropTypes.number,
  ])
}

export default Block
